{  Statement: http://acmp.ru/?main=task&id_task=89
   Verdict: Accepted
}
uses
        SysUtils, Math;

const
    eps:double = 1e-6;

type
    train = record
        n:string;
        s:double;
    end;

var
    i,n,x,y,kk,mx:longint;
    a:array[0..110] of train;
    s:string;

begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(n);
mx := 0;
for i:=1 to n do begin
    readln(s);
    delete(s, 1, 1);
    kk := pos('"',s);
    a[i].n := '"' + copy(s, 1, kk);
    delete(s, 1, kk + 1);
    x := strtoint(s[1] + s[2]) * 60 + strtoint(s[4] + s[5]);
    delete(s, 1, pos(' ',s));
    y := strtoint(s[1] + s[2]) * 60 + strtoint(s[4] + s[5]);
    if y <= x then inc(y, 1440);
    a[i].s := 650 / (y - x) * 60;
    if a[i].s - a[mx].s > eps then mx := i;     
end;
writeln('The fastest train is ',a[mx].n,'.');
write('It',#39,'s speed is ',round(a[mx].s),' km/h, approximately.');
end.
